# Definition for a binary tree node.
class TreeNode(object):
    def __init__(self, x):
        self.val = x
        self.left = None
        self.right = None

class Solution(object):
    def isSameTree(self, p, q):
        """
        :type p: TreeNode
        :type q: TreeNode
        :rtype: bool
        """
        if p and q:
            if p.val == q.val and self.isSameTree(p.left,q.left) and self.isSameTree(p.right,q.right):
                return True
            else:
                return False

        return p==q



m = TreeNode(1)
m.left = TreeNode(2)


m1 = TreeNode(1)
m1.left = TreeNode(2)
m1.right = TreeNode(3)

s = Solution()

t = s.isSameTree(m,m1)
print(t)
